import OPi.GPIO as GPIO
import orangepi.zero
import time

class duoji:
    def __init__(self):
        self.pin=12
        BOARD = orangepi.zero.BOARD
        GPIO.cleanup()
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(self.pin, GPIO.OUT)
        self.pwm = GPIO.PWM(self.pin, 50)
        self.pwm.start(0)
    def yaobai(self):
        c=0
        ts = int((c/180*2+0.5)/20*1023)
        self.pwm.ChangeDutyCycle(ts)
        time.sleep(2)
        c=90
        ts = int((c/180*2+0.5)/20*1023)
        self.pwm.ChangeDutyCycle(ts)
        time.sleep(2)
if __name__ == '__main__':
    GPIO.setwarnings(False)
    dj=duoji()
    dj.yaobai()
# def tenstep():
#     c=0
#     pwm=PWM(Pin(5,Pin.OUT))
#     pwm.freq(50)
#     while True:
#         while c <= 180 :
#             ts = int((c/180*2+0.5)/20*1023)
#             pwm.duty(ts)
#             time.sleep(1)
#             c=c+10
#         while c <= 190 and c >= 10:
#             c=c-10
#             ts = int((c/180*2+0.5)/20*1023)
#             pwm.duty(ts)
#             time.sleep(1)
#             
# def tan(n):
#     pwm=PWM(Pin(5,Pin.OUT))
#     pwm.freq(50)
#     if n==1:
#         c=0
#         ts = int((c/180*2+0.5)/20*1023)
#         pwm.duty(ts)
#         time.sleep(2)
#     if n==2:
#         c=90
#         ts = int((c/180*2+0.5)/20*1023)
#         pwm.duty(ts)
#         time.sleep(2)
# 
# def ninety():
#     pwm=PWM(Pin(5,Pin.OUT))
#     pwm.freq(50)
#     if n==1:
#         c=90
#         ts = int((c/180*2+0.5)/20*1023)
#         pwm.duty(ts)
#         time.sleep(2)
#         
# def yaobai():
#     c=0
#     ts = int((c/180*2+0.5)/20*1023)
#     pwm.duty(ts)
#     time.sleep(2)
#     c=90
#     ts = int((c/180*2+0.5)/20*1023)
#     pwm.duty(ts)
#     time.sleep(2)
# tan(2)
# tan(1)
# c=120
# ts = int((c/180*2+0.5)/20*1023)
# pwm.duty(ts)
# time.sleep(1)